﻿using System.Xml;
using CLFramework.Configuration;
using CLFramework.WinService;

namespace CLFramework.WinService
{
    public class WinServiceSetting
    {
        public WinServiceSetting(XmlNode node)
        {
            XmlAttributeCollection atts = node.Attributes;
            this.ServiceRealName = ConfigurationBase.GetStringAttribute(atts, "name", string.Empty);
            this.ServiceDisPlayName = ConfigurationBase.GetStringAttribute(atts, "displayname", string.Empty);
            this.ServiceDescription = ConfigurationBase.GetStringAttribute(atts, "description", string.Empty);
            this.LogToFile = ConfigurationBase.GetBoolAttribute(atts, "logtofile", true);
            this.ClearConsoleInterval = ConfigurationBase.GetIntAttribute(atts, "clearconsoleinterval", 600000);
            this.MainTaskInterval = ConfigurationBase.GetIntAttribute(atts, "maintaskinterval", 1000);
            this.BreathInterval = ConfigurationBase.GetIntAttribute(atts, "breathinterval", 50);
            this.RunOnce = ConfigurationBase.GetBoolAttribute(atts, "runonce", false);
            this.ThreadCount = ConfigurationBase.GetIntAttribute(atts, "threadcount", 1);
        }

        public string ServiceRealName { get; set; }
        public string ServiceDisPlayName { get; set; }
        public string ServiceDescription { get; set; }

        public bool LogToFile { get; set; }
        public bool RunOnce { get; set; }

        public int ClearConsoleInterval { get; set; }
        public int MainTaskInterval { get; set; }
        public int BreathInterval { get; set; }
        public int ThreadCount { get; set; }
    }
}
